COBJS   := $(sort $(COBJS-y))
AOBJS   := $(sort $(AOBJS-y))
SRCS    := $(AOBJS:.o=.S) $(COBJS:.o=.c)
OBJS    := $(AOBJS) $(COBJS)

all:	built-in.o

built-in.o:	$(OBJS)
	$(LD) -r -o $@ $^  

sinclude .depend

.depend:	Makefile $(TOPDIR)/config.mk $(SRCS)
	@rm -f $@
	@for f in $(SRCS); do \
		g=`basename $$f | sed -e 's/\(.*\)\.\w/\1.o/'`; \
		$(CC) -M $(CPPFLAGS) -MQ $(obj)$$g $$f >> $@ ; \
	done

$(obj)%.o:	%.S
	$(CC)  $(AFLAGS) -o $@ $< -c
$(obj)%.o:	%.c
	$(CC)  $(CFLAGS) -o $@ $< -c

